package com.shtel.bss.saas.core.data.common.mapper;

import com.shtel.bss.saas.core.base.spring.ApplicationContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

/**
 * @author xiezhiwei
 * @version Revision 1.0
 * @版权： 版权所有 (c) 2018
 * @创建日期： 2020/2/4 15:18
 * @功能说明：
 */
public class MapperFactory {

	private static final Logger LOG = LoggerFactory.getLogger(
		MapperFactory.class);

	public static <T> IBaseMapper getMapper(Class<T> clazz) {
		String mapperName = StringUtils.uncapitalize(clazz.getSimpleName() + "Mapper");
		IBaseMapper t = null;
		if (!ApplicationContextUtil.containsBean(mapperName)) {
			//TODO
//			throw new RtManagerException(mapperName + " is not exists.");
		} else {
			t = (IBaseMapper) ApplicationContextUtil.getBean(mapperName);
			return t;
		}
		return t;
	}
}
